<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>玉灵 QQ:7031633 Email:webrx@126.com</title>
    <meta name="keywords" content="关键字">
    <meta name="description" content="简介">
    <link rel="stylesheet" href="/static/plug/layui-admin/dist/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/common/css/login.css"/>
    <style th:inline="none">
        #logo {
            width: 176px;
            height: 42px
        }
    </style>
</head>

<body>


<div class="login">
    <div class="logo">
        <img style="width: auto;height: 42px" src="/static/common/image/login/logo.png"/>
    </div>
    <div class="login-form-box">
        <div class="login-left">
            <div class="login-left-img">
                <img src="/static/common/image/login/login_form_img.png"/>
            </div>
        </div>
        <div class="login-right">
            <div class="login-form layui-form">
                <div class="login-title">
                    优选商城后台管理系统
                </div>
                <div class="form-box-item">
                    <div class="icon">
                        <img src="/static/common/image/login/login_number.png">
                    </div>
                    <div>
                        <input type="text" name="account" lay-verify="required" lay-vertype="tips"
                               class="layui-input" style="border:none;width: 150px;padding-left: 20px;"
                               placeholder="请输入账号" value="admin">
                    </div>
                </div>
                <div class="form-box-item">
                    <div class="icon">
                        <img src="/static/common/image/login/login_password.png"/>
                    </div>
                    <div>
                        <input type="password" name="password" lay-verify="required" lay-vertype="tips"
                               class="layui-input" style="border:none;width: 150px;padding-left: 20px;" value="123456"
                               placeholder="请输入密码"/>
                    </div>
                </div>
                <div class="form-box-item">
                    <div class="icon">
                        <img src="/static/common/image/login/login_code.png"/>
                    </div>
                    <div style="display: flex; align-items: center; justify-content: space-between;">
                        <input type="text" name="code" lay-verify="required" lay-vertype="tips" style="border:none;width: 150px;padding-left: 20px;" th:value="${session.captcha}" placeholder="请输入验证码"/>
                        <img style="height: 36px;width: 126px;" src="/admin/captcha" onfocus="this.value = ''" class="layadmin-user-login-codeimg" id="captcha">
                    </div>
                </div>
                <div class="form-box-checked">
                    <div>
                        <input type="checkbox" lay-skin="primary" name="remember_account" title="记住账号">
                    </div>
                </div>
                <button id="login" lay-filter="login" class="submit-btn" lay-submit style="background-color: #2C85EA">登录</button>
            </div>
        </div>
    </div>
    <footer>
        Copyright © 2001-2021 优选好物&nbsp;&nbsp;<a target="_blank" href="#">13014577033</a>&nbsp;&nbsp;
    </footer>
</div>
<script src="/static/plug/layui-admin/dist/layuiadmin/layui/layui.js"></script>
</body>
<script th:inline="none">
    if (self !== top) {
        parent.window.location.replace(window.location.href);
    }
    layui.config({
        base: '/static/plug/layui-admin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'user', 'like'], function () {
        var $ = layui.$
            , like = layui.like
            , form = layui.form
        form.render();

        //更换图形验证码
        $('body').on('click', '#captcha', function () {
            var othis = $(this);
            this.src = '/admin/captcha?t=' + Date.now();
        });

        function login(obj) {
            like.ajax({
                url: '/admin/checklogin' //实际使用请改成服务端真实接口
                , data: obj.field
                , dataType: 'json'
                , type: 'post'
                , success: function (res) {
                    if (res.code === 1) {
                        layer.msg(res.msg, {
                            offset: '15px'
                            , icon: 1
                            , time: 1000
                        }, function () {
                            location.href = '/admin/'; //后台主页
                        });
                    } else {
                        layer.msg(res.msg, {
                            icon: 2,
                            time: 1000
                        }, function () {
                            $('#captcha').attr('src', '/admin/captcha?t=' + Date.now());
                        });
                    }

                },
            });
        }

        //提交
        form.on('submit(login)', function (obj) {
            console.log(13014577033);
            login(obj);
        });


        $('[name="account"]').keyup(function (event) {
            if (event.keyCode === 13) {
                $('#login').trigger('click');
            }
        });
        $('[name="password"]').keyup(function (event) {
            if (event.keyCode === 13) {
                $('#login').trigger('click');
            }
        });
        $('[name="code"]').keyup(function (event) {
            if (event.keyCode === 13) {
                $('#login').trigger('click');
            }
        });
    });
</script>
</html>